function str = cvc_read_edat_str(edatfile,colname)
% CVC_READ_EDAT_STR
%
%  Synopsis
%  ========
%
%  str = cvc_read_edat_str(edatfile,colname)
%
%  -- Author: Mads Dyrholm --
%     Center for Visual Cognition, University of Copenhagen.
%     April 2011
%
%  Purpose
%  =======
%
%  Read a column of strings from edat in excel format
%  without unicode.
%
%  Inputs
%  ======
%  
%  edatfile - Filename of the edat excel file.
%
%  colname - string giving the name of the Column.
%
%  Output
%  ======
%
%  str - Cell array of strings read from the column, one 
%  cell per trial.

qq=textread(edatfile,'%s','delimiter','\n');
ww = textscan(qq{2},'%s','delimiter','\t');
MM = length(qq)-2;
fprintf('CVC: Found %i trials in the edat file. \n',MM);
NN = length([ww{:}]);
fprintf('CVC: Found %i columns in the edat file. \n',NN);
EDAT = cell(MM,NN);
for ii=1:MM
  ee = textscan([qq{ii+2} sprintf('\t.')],'%s','delimiter','\t'); % added '\t.' to fix problem with empty cells in end of row
  for jj=1:NN
    EDAT{ii,jj} = ee{1}(jj);
  end
end
% find the stuff
Stuffcol = [];
for col=1:NN
  if  strcmp(ww{1}(col),colname);
    Stuffcol = col;
    break;
  end
end
if isempty(Stuffcol)
  fprintf('CVC: Error. Column not found in edat. STOP.\n');
  return
end
%
str=EDAT(:,Stuffcol);
str=[str{:}];
